package com.immortal.core.module.version.core;

/**
 * <p>TODO
 *
 * @author wind
 * @version 1.0
 * @since 2018/12/19
 */
public enum VersionOperator {
    /**
     * 空
     */
    NIL(""),
    /**
     * <
     */
    LT("<"),
    /**
     * >
     */
    GT(">"),
    /**
     * <=
     */
    LTE("<="),
    /**
     * >=
     */
    GTE(">="),
    /**
     * !=
     */
    NE("!="),
    /**
     * ==
     */
    EQ("==");
    private String code;

    VersionOperator(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public static VersionOperator parse(String code) {
        for (VersionOperator operator : VersionOperator.values()) {
            if (operator.getCode().equalsIgnoreCase(code)) {
                return operator;
            }
        }
        return null;
    }

}
